$(function () {
    validateUpdatePasswordRule();
});
function validateUpdatePasswordRule() {
    var icon = "<i class='zmdi zmdi-close-circle zmdi-hc-fw'></i> ";
    $("#user-password").validate({
        rules: {
            newPassword: {
                required: true,
                minlength: 6
            },
            confirm: {
                required: true,
                equalTo: "#newPassword"
            }
        },
        messages: {
            newPassword: {
                required: icon + "请输入新密码",
                minlength: icon + "密码不能小于6个字符"
            },
            confirm: {
                required: icon + "请再次输入新密码",
                equalTo: icon + "两次密码输入不一致"
            }
        }
    });
}
/**保存**/
function save_index_password() {
    var validateUpdatePassword = $("#user-password").validate();
    var flag = validateUpdatePassword.form();
    var usernameUpdate = sessionStorage.getItem("usernameUpdate");
    if (flag) {
        $.post(ctx + "user/updatePassword", $("#user-password").serialize()+"&username="+usernameUpdate, function (r) {
            if (r.code === 0) {validateUpdatePassword.resetForm();
            $("#index_user_password").empty().modal("hide");
        $JuXue.n_success(r.msg);} else $JuXue.n_danger(r.msg);});
    }
}